/**
 * 
 */
package se.thoka.twt.client.application;

import com.google.gwt.event.shared.GwtEvent;

/**
 * @author Thobias Karlsson, Thoka
 * @since 9 jan 2010
 */
public class HistoryChangedEvent extends GwtEvent<HistoryChangedHandler> {
	
	private static Type<HistoryChangedHandler> TYPE = new Type<HistoryChangedHandler>();
	
	private String newHistory, oldHistory;
	
	/**
	 * Creates a new instance of {@link HistoryChangedEvent}.
	 * @param newHistory The new history token
	 * @param oldHistory The old history token
	 */
	public HistoryChangedEvent(String newHistory, String oldHistory) {
		this.newHistory = newHistory;
		this.oldHistory = oldHistory;
	}
	
	/**
	 * @return The new history token
	 */
	public String getNewHistory() {
		return newHistory;
	}
	
	/**
	 * @return The old history token
	 */
	public String getOldHistory() {
		return oldHistory;
	}

	@Override
	protected void dispatch(HistoryChangedHandler handler) {
		handler.onHistoryChanged(this);
	}

	@Override
	public Type<HistoryChangedHandler> getAssociatedType() {
		return getType();
	}

	/**
	 * @return The event type
	 */
	public static Type<HistoryChangedHandler> getType() {
		return TYPE;
	}
}
